
function getGoogleShortenerURL() {
	const server		= "http://ggl-shortener.appspot.com/";
	const clipBoard	= Components.
		classes["@mozilla.org/widget/clipboardhelper;1"].
			getService(Components.interfaces.nsIClipboardHelper);

	var url = encodeURIComponent(window.top.getBrowser().currentURI.spec);
	var opts		= [
		 ["url",		url].join("=")
		].join("&");
	var query			= [server, opts].join("?");

	var req = new XMLHttpRequest();
	
	req.addEventListener("load", function() {
		var res = JSON.parse(req.responseText);
		if (res.error_message) {
			throw new Error("Error at getGoogleShortenerURL : "+res.error_message);
		} else {
			clipBoard.copyString(res.short_url);
		}
	}, false);

	req.open("GET", query);
	req.send();
}
